package com.sumainfor.pc.gmio.service.impl;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.gmio.feign.Zfeign.ZpcEpcFeign;
import com.sumainfor.pc.gmio.feign.Zfeign.ZpcMktFeign;
import com.sumainfor.pc.gmio.service.DiRepairService;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;

/**
 * 退租账单
 */
@Service
public class DiRepairSerivceImpl implements DiRepairService {

    private ReentrantLock lock = new ReentrantLock(false);
    Logger log = LoggerFactory.getLogger(DiRepairSerivceImpl.class);
    @Autowired
    private ZpcMktFeign zpcMktFeign;
    @Autowired
    private ZpcEpcFeign zpcEpcFeign;

    /**
     * 查询维修跟踪列表 待受理
     * @param params
     * @return
     */
/*    @Override
    public JsonResult getRepairListd(Map<String, Object> params, Pager pager) {
        //查询工程部的维修工单信息和房源编号
        JsonResult epcResult=zpcEpcFeign.getRepairListFromGmiod(params);
        System.out.println("工程部查询到信息:"+epcResult);
        //保存工程部查询到的id集合
        List<String> idList=new ArrayList<String>();
        if (epcResult.get("errorCode").equals("0")) {
            List<Map<String,Object>> list= (List<Map<String,Object>>)epcResult.get("result");
            for (Map<String,Object> map: list){
                if(map.get("HouId")!=null){
                    idList.add(map.get("HouId").toString());
                }
            }
            if (idList!=null && idList.size()>0) {
                pager.setPagerNecessary(params, pager);
                System.out.println("传递到市场部的参数:" + params);
                JsonResult mktResult = zpcMktFeign.getHouInfoListForRepair(params, pager, idList);
                System.out.println("市场部查询到信息:" + mktResult);
                if (epcResult.get("errorCode").equals("0")) {
                    Map<String, Object> mktMap = (Map<String, Object>) mktResult.get("result");
                    List<Map<String, Object>> mktlist = (List<Map<String, Object>>) mktMap.get("dataList");
                    for (Map<String, Object> map : list) {
                        for (Map<String, Object> map2 : mktlist) {
                            if (MapUtils.getString(map, "HouId").equals(MapUtils.getString(map2, "HouId"))) {
                                map2.putAll(map);
                            }
                        }
                    }
                }
                return mktResult;
            }
        }
        return epcResult;
    }*/
    /**
     * 查询维修跟踪列表 已受理
     * @param params
     * @return
     */
/*    @Override
    public JsonResult getRepairListy(Map<String, Object> params, Pager pager) {
        //查询工程部的维修工单信息和房源编号
        JsonResult epcResult=zpcEpcFeign.getRepairListFromGmioy(params);
        System.out.println("工程部查询到信息:"+epcResult);
        //保存工程部查询到的id集合
        List<String> idList=new ArrayList<String>();
        if (epcResult.get("errorCode").equals("0")) {
            List<Map<String,Object>> list= (List<Map<String,Object>>)epcResult.get("result");
            for (Map<String,Object> map: list){
                if(map.get("HouId")!=null){
                    idList.add(map.get("HouId").toString());
                }
            }
            if (idList!=null && idList.size()>0) {
                pager.setPagerNecessary(params, pager);
                System.out.println("传递到市场部的参数:" + params);
                JsonResult mktResult = zpcMktFeign.getHouInfoListForRepair(params, pager, idList);
                System.out.println("市场部查询到信息:" + mktResult);
                if (epcResult.get("errorCode").equals("0")) {
                    Map<String, Object> mktMap = (Map<String, Object>) mktResult.get("result");
                    List<Map<String, Object>> mktlist = (List<Map<String, Object>>) mktMap.get("dataList");
                    for (Map<String, Object> map : list) {
                        for (Map<String, Object> map2 : mktlist) {
                            if (MapUtils.getString(map, "HouId").equals(MapUtils.getString(map2, "HouId"))) {
                                map2.putAll(map);
                            }
                        }
                    }
                }
                return mktResult;
            }
        }
        return epcResult;
    }*/
    /**
     * 查询维修跟踪列表 已维修
     * @param params
     * @return
     */
 /*   public JsonResult getRepairListw(Map<String, Object> params, Pager pager) {
        //查询工程部的维修工单信息和房源编号
        JsonResult epcResult=zpcEpcFeign.getRepairListFromGmiow(params);
        System.out.println("工程部查询到信息:"+epcResult);
        //保存工程部查询到的id集合
        List<String> idList=new ArrayList<String>();
        if (epcResult.get("errorCode").equals("0")) {
            List<Map<String,Object>> list= (List<Map<String,Object>>)epcResult.get("result");
            for (Map<String,Object> map: list){
                if(map.get("HouId")!=null){
                    idList.add(map.get("HouId").toString());
                }
            }
            if (idList!=null && idList.size()>0) {
                pager.setPagerNecessary(params, pager);
                System.out.println("传递到市场部的参数:" + params);
                JsonResult mktResult = zpcMktFeign.getHouInfoListForRepair(params, pager, idList);
                System.out.println("市场部查询到信息:" + mktResult);
                if (epcResult.get("errorCode").equals("0")) {
                    Map<String, Object> mktMap = (Map<String, Object>) mktResult.get("result");
                    List<Map<String, Object>> mktlist = (List<Map<String, Object>>) mktMap.get("dataList");
                    for (Map<String, Object> map : list) {
                        for (Map<String, Object> map2 : mktlist) {
                            if (MapUtils.getString(map, "HouId").equals(MapUtils.getString(map2, "HouId"))) {
                                map2.putAll(map);
                            }
                        }
                    }
                }
                return mktResult;
            }
        }
        return epcResult;
    }*/
}
